<%@page import="com.googlecode.contests_repo.core.config.ConfigurationManager"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Registration page</title>
</head>
<body>
	<center>
		<h3>Welcome to the registration page!</h3>
	</center>
	<br>
	
	<jsp:useBean id="user" class="com.googlecode.contests_repo.core.users.User" scope="request">
		<jsp:setProperty name="user" property="*"/>
	</jsp:useBean>
	<%@ page import="com.googlecode.contests_repo.core.users.*" %>	
	<%	
		if(request.getParameter("formSubmitted") != null) {
			if (user.validate())	{
				UserManager.saveUser(user);
	%>		
	 			<jsp:forward page="Home.jsp"/> 
	<%		
			}
		}
	%>
	<div class="form">
	<form method="post">
		<div>
		<label>Username<span>*</span>:</label> <input type="text" name="login" value="<%= user.getLogin() %>">
		<span class="errorMsg"> <%= user.getValidationError("login") %> </span>
		</div> 
		<div>
		<label>Password<span>*</span>:</label> <input type="password" name="password">
		<span class="errorMsg"> <%= user.getValidationError("password") %> </span> 
		</div>
		<div>
		<label>Repeat password<span>*</span>:</label> <input type="password" name="confirmPassword"> 
		</div>
		<div>
		<label>E-mail<span>*</span>:</label> <input type="text" name="email" value="<%= user.getEmail() %>">
		<span class="errorMsg"> <%= user.getValidationError("email") %> </span> 
		</div>
		<div>		
		<label>Real name<span>*</span>:</label> <input type="text" name="realName" value="<%= user.getRealName() %>">
		<span class="errorMsg"> <%= user.getValidationError("realName") %> </span> 
		</div>
		<div>		
		<label>City:</label> <input type="text" name="city" value="<%= user.getCity() %>">
		</div>
		<div> 
		<label>Organization:</label> <input type="text" name="organizations" value="<%= user.getOrganizations()[0] %>">
		</div>
		<div>
		<label>About:</label> <textarea rows="3" cols="40" name="about" ><%= user.getAbout() %></textarea>
		</div>
		<input type="hidden" name="formSubmitted" value="true"/>
		<input class= "submit" type="submit" value="Register"/>
	</form>
	</div>

</body>
</html>